//
//  CommentSuccessCell.m
//  LvXi_newVersion
//
//  Created by 王敏 on 16/9/5.
//  Copyright © 2016年 SJT. All rights reserved.
//

#import "CommentSuccessCell.h"
@interface CommentSuccessCell ()

@property(nonatomic,strong)UIImageView * productImageView;

@property(nonatomic,strong)UILabel * nameLabel;

@property(nonatomic,strong)UILabel * priceLabel;


@end
@implementation CommentSuccessCell
-(id)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self.contentView addRadius:10];
        
        
        self.productImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.productImageView.image = [UIImage imageNamed:@"localDetailIMage_1"];
        [self.contentView addSubview:self.productImageView];
        
        self.nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.nameLabel.font = [UIFont systemFontOfSize:12];
        self.nameLabel.text = @"风格很好独一份给";
        self.nameLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.nameLabel];
        
        self.priceLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.priceLabel.textColor = [UIColor orangeColor];
        self.priceLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.priceLabel];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.productImageView.size = CGSizeMake(self.width-2*globalMargin, self.width-2*globalMargin);
    self.productImageView.x = globalMargin;
    self.productImageView.y = globalMargin;
    
    self.nameLabel.size = CGSizeMake(self.width - 2*globalMargin, 15);
    self.nameLabel.x = globalMargin;
    self.nameLabel.y = self.productImageView.botton + globalMargin;
    

    self.priceLabel.height = self.priceLabel.attributedText.size.height;
    self.priceLabel.width = self.width;
    self.priceLabel.centerX = self.width*0.5;
    self.priceLabel.y = self.nameLabel.botton+globalMargin;
}
-(void)setPrice:(NSString *)price{
    _price = [price addHeader:@"¥ "];
    
    NSMutableAttributedString * attr = [[NSMutableAttributedString alloc] initWithString:_price];
    [attr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} range:NSMakeRange(0, 1)];
    [attr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]} range:NSMakeRange(2, _price.length-2)];
    self.priceLabel.attributedText = attr;
    
    [self setNeedsLayout];
}
@end
